<!DOCTYPE html>
<div id="container" style="position: absolute; width: 500px; height: 500px; background-color: blue">
  ABCD<img id="percent-height-in-anonymous" style="height: 20%; width: 50px;">
  <div id="percent-height-direct-child" style="height: 20%; background-color: red"></div>
</div>